//
//  HJDFileViewController.m
//  JYHospital
//
//  Created by 胡金东 on 16/5/17.
//  Copyright © 2016年 胡金东. All rights reserved.
//

#import "HJDFileViewController.h"
#import "HJDFileViewCell.h"
#import "HJDFileModel.h"
#import "HJDDateilsViewController.h"


@interface HJDFileViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong) UITableView * tableView;

@property (nonatomic,strong) NSArray * filesArray;



@end

@implementation HJDFileViewController

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
    self.navigationItem.rightBarButtonItem = nil;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"孕期档案";
    [self.navigationController.navigationBar setTitleTextAttributes:
     @{NSFontAttributeName:[UIFont systemFontOfSize:19],
       NSForegroundColorAttributeName:[UIColor getColorWithHexNumber:@"848484"]}];

    
   [self setUpTableView];
}

-(void)setUpTableView
{
    self.tableView = [[UITableView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.filesArray = [HJDFileModel fileArray];
    [self.view addSubview:self.tableView];
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.filesArray.count;
   
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *identifier = @"Cell";
    HJDFileViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[HJDFileViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    HJDFileModel * model = self.filesArray[indexPath.row];
    cell.dateLbl.text = model.date;
    cell.yearLbl.text = model.year;
    cell.nameLbl.text = @"检查医生：";
    cell.cnameLbl.text = model.name;
    cell.projectLbl.text = @"产检项目：";
    cell.cprojectLbl.text = model.project;
    cell.numLbl.text = @"产检次数：";
    cell.cnumLbl.text = model.num;
    cell.weekLbl.text = model.week;


    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 200;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   HJDDateilsViewController *detail = [[HJDDateilsViewController alloc]init];
    
    detail.fileModel = [HJDFileModel fileArray][indexPath.row];
    [self.navigationController pushViewController:detail animated:YES];
}

@end
